package com.strato.passport.client.v1_0_0.http;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;

public class HttpClientFactory {

	private static boolean _inited = false;

	private static CloseableHttpClient httpclient;
	
	public synchronized static void _init() {
		if (_inited) {
			return;
		}
		PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
		cm.setDefaultMaxPerRoute(100);
		HttpClientBuilder builder = HttpClients.custom().setConnectionManager(cm);
		httpclient=builder.build();
		_inited = true;
	}

	public static CloseableHttpClient getHttpClient() {
		_init();
		return httpclient;
	}

}
